package com.taritari.journal.rabbitmq;

import com.alibaba.fastjson.JSONObject;
import com.taritari.journal.entity.dto.CommentRoBotDto;
import com.taritari.journal.entity.dto.UserLikeDto;
import com.taritari.journal.services.CommentService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author taritari
 * @date 2024-01-25 18:12
 * @description 评论机器人队列
 */
@Service
@RabbitListener(queues = {"comment_robot"}) //队列名
public class CommentRobotConsumer {
    @Autowired
    private CommentService commentService;
    @RabbitHandler
    public void receiveMessage(String message){
        CommentRoBotDto commentRoBotDto = JSONObject.parseObject(message, CommentRoBotDto.class);
        System.out.println("==========================接收消息==========================");
        System.out.println(commentRoBotDto);
        commentService.botComment(commentRoBotDto.getText(), commentRoBotDto.getNumber());

    }
}
